<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<style type="text/css">
	label.col-2{width: 120px;}
	.adblank{margin-bottom:20px; background-color:#f3f7ff; padding:10px; position: relative;}
	.adblank .del{position:absolute; right: -6px; top: -20px; font-size: 26px; cursor: pointer;}
	#filePicker{float: inherit;}
	.uploader-list img{max-height: 100px;}
	.btnadd{font-size:55px;  cursor: pointer;}
</style>
<title>新增广告</title>
</head>
<body>
	<form action="" method="post" class="form form-horizontal" id="form1">
<div class="pd-20">

		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>广告名称：</label>
			<div class="formControls col-6">
				<input type="text" class="input-text" value="" placeholder="" id="ad_title" name="ad_title" nullmsg="广告名称不能为空！" datatype="s1-100">
			</div>
			<div class="col-3"> </div>
		</div>




		<!-- <div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>选择广告位：</label>
			<div class="formControls col-2"> <span class="select-box">
				<select class="select" size="1" name="article_tpl" id="cid">
	            </select>
				</span> 
			</div>
		</div> -->

		<div class="row cl" style="position: relative;">
			
			<label class="form-label col-2"><span class="c-red">*</span>时间范围：</label>
			<div class="col-5" style="position:relative;">
				<!-- <div style="background-color: red; opacity: 0; position: absolute; left: 0px; width: 100%; height: 30px; z-index: 100" class="" id="date-range16-open"></div> -->
				<div class="formControls" style="display: flex;">
					<input type="text" id="date-range16" name="time" class="input-text datainp" nullmsg="开始时间不能为空！" datatype="*1-100">
				</div>
			</div>
		
			<label class="col-3 pd-5" style="margin-right:5px;"><input type="checkbox" name="forever" value="1">永不过期</label>
			
			<!-- <div class="col-1"> </div> -->
		</div>
		
		
		<div class="row cl">
			<label class="form-label col-2"><!-- <span class="c-red">*</span> -->状态：</label>
			<div class="formControls col-8 s-msg" style="padding-top: 2px;">
			    <div class="radio-box">
			        <input type="radio" id="radio-1" name="ad_state" value="1" checked>
			        <label for="radio-1" class="lh-26">显示</label>
			    </div>
			    <div class="radio-box">
			        <input type="radio" id="radio-2" name="ad_state" value="0">
			        <label for="radio-2" class="lh-26">不显示</label>
			      </div>
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-2"><!-- <span class="c-red">*</span> -->是否上架：</label>
			<div class="formControls col-8 s-msg" style="padding-top: 2px;">
			    <div class="radio-box">
			        <input type="radio" id="radio-3" name="is_public" value="1" checked>
			        <label for="radio-3" class="lh-26">显示</label>
			    </div>
			    <div class="radio-box">
			        <input type="radio" id="radio-4" name="is_public" value="0">
			        <label for="radio-4" class="lh-26">不显示</label>
			      </div>
			</div>
		</div>
		

		<div class="row cl">
			<label class="form-label col-2">
				广告图片：<br>
				
				<!-- <i class="icon Hui-iconfont" id="add" style="font-size:50px; margin-right:15px; cursor: pointer;" title="添加广告"></i> -->
			</label>
			<div class="formControls col-9"  style="min-height:100px;">
				
				<div id="adlist" style="">
					<div class="adblank">
						<i class="icon Hui-iconfont del"></i>
						<div id="fileList1" class="uploader-list"></div>
						<p>主标题:<input type="text" class="input-text" value="" placeholder="" name="title1[]"></p>
						<!-- <p>副标题:<input type="text" class="input-text" value="" placeholder="" name="title2[]"></p> -->
						<!-- <p>背景色:<input type="text" class="input-text" value="" placeholder="" name="bgcolor[]"></p> -->
						<p>Wechat链接地址:<input type="text" class="input-text" value="" placeholder="" name="url[]"></p>

						<p>IOS链接地址:<input type="text" class="input-text" value="" placeholder="" name="ios_url[]"></p>
						<p>Android链接地址:<input type="text" class="input-text" value="" placeholder="" name="android_url[]"></p>

						<p>描述:<input type="text" class="input-text" value="" placeholder="" name="desc[]"></p>
						<div id="filePicker" class="btn btn-secondary radius" onclick="_open('添加附件','article-imageupload.html?type=image&idname=fileList1&api=ad&single=1&inputname=img[]','710px','470px',true)">选择图片</div>
					</div>
				</div>
				<div><i class="icon Hui-iconfont btnadd" id="add" ></i></div>
				
			</div>
			
		</div>

		<div class="row cl">
			<label class="form-label col-2">广告详情：</label>
			<div class="formControls col-10"> 
				<script id="editor" name="ad_brief" type="text/plain" ></script> 
			</div>
		</div>

		
		
		
		

		<!-- 
		<div class="row cl">
			<div class="col-10 col-offset-2">
				<button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
				<button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div> -->
	
</div>
<div class="row cl pr-20" style="position:fixed; bottom:10px; width: 200px; right: 10px; text-align: right; z-index:1000; ">
	
		<button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
		<button onClick="removeIframe();" class="btn btn-default radius" type="button" style="margin-left:10px;">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
	
</div>
</form>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.1/layer.js"></script> 

<script type="text/javascript" src="lib/Validform/5.3.2/Validform.min.js"></script> 
<script type="text/javascript" src="lib/webuploader/0.1.5/webuploader.min.js"></script> 
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.config.js"></script> 
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.all.min.js"> </script> 
<script type="text/javascript" src="lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script> 
<script type="text/javascript" src="js/H-ui.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script> 
<script type="text/javascript" src="js/template-native.js"></script> 
<script type="text/javascript" src="js/s.js"></script> 

<script type="text/javascript" src="lib/daterangepicker/moment.min.js"></script> 
<script type="text/javascript" src="lib/daterangepicker/jquery.daterangepicker.js"></script>
<link rel="stylesheet" href="lib/daterangepicker/daterangepicker.css" /> 

<script type="text/javascript">
var classid;
var index=2;
function tt(){
		alert("000");
	}

$(function(){
	$(document).on('click','i#add',function(){
		console.log("index:"+index);

		

		$("#adlist").append('<div class="adblank"><i class="icon Hui-iconfont del"></i><div id="fileList'+index+'" class="uploader-list"></div><p>主标题:<input type="text" class="input-text" value="" placeholder="" name="title1[]"></p><p>Wechat链接地址:<input type="text" class="input-text" value="" placeholder="" name="url[]"></p><p>IOS链接地址:<input type="text" class="input-text" value="" placeholder="" name="ios_url[]"></p><p>Android链接地址:<input type="text" class="input-text" value="" placeholder="" name="android_url[]"></p><p>描述:<input type="text" class="input-text" value="" placeholder="" name="desc[]"></p><div id="filePicker" class="btn btn-secondary radius" onclick="_open(\'添加附件\',\'article-imageupload.html?type=image&idname=fileList'+index+'&api=ad&single=1&inputname=img[]\',\'710px\',\'470px\',true)">选择图片</div></div>');
		index++;
	
	});

	$(document).on('click','i.del',function(){
		$(this).parent(".adblank").remove();
	})
	
	


	
	$('#date-range16').dateRangePicker(
	{
		startOfWeek: 'monday',
		separator : ' 至 ',
		format: 'YYYY-MM-DD HH:mm',
		autoClose: true,
		time: {
			enabled: true
		},
		defaultTime: moment().startOf('day').toDate(),
		defaultEndTime: moment().endOf('day').toDate()
	});

	$('#date-range16-open').click(function(evt)
	{
		evt.stopPropagation();
		$('#date-range16').data('dateRangePicker').open();
	});

	// 设置默认时间，今天开始，一个月后结束
	var rangetiem=getNowTime()+' 至 '+getNowTime2(1);
	$("input[name=time]").val(rangetiem);
	

	var editid=getUrlParam('editid');//编辑菜单id
	if(editid==null){
	    $("#form1").attr("action", API_AD);
	     
	}else{
	    var eidturl=API_AD+"?id="+editid;
	    // 读取即将编辑的广告信息
	    $.getJSON(eidturl,function(data){
	    	if(!checkStatus(data)) return;
	        
	            $("#ad_title").val(data.datas.ad_title);
	            $("input[name=time]").val(data.datas.ad_addtime+' 至 '+data.datas.ad_endtime);
	            
	            $("#form1").attr("action", eidturl);
	           
	            if(data.datas.ad_content!==""){
	            	$("#adlist").empty();
	            	
	            	
	            	for (x in data.datas.ad_content){
	            		var i=parseInt(x)+1;
	            		var boxid="#fileList"+i;
	            		var desc=data.datas.ad_content[x].desc;

	            		var titlemain=data.datas.ad_content[x].title1;

	            		var linkurl=data.datas.ad_content[x].url;
	            		var ios_linkurl=data.datas.ad_content[x].ios_url;
	            		var android_linkurl=data.datas.ad_content[x].android_url;

	            		$("#adlist").append('<div class="adblank"><i class="icon Hui-iconfont del"></i><div id="fileList'+i+'" class="uploader-list"></div><p>主标题:<input type="text" class="input-text" value="'+titlemain+'" placeholder="" name="title1[]"></p><p>Wechat链接地址:<input type="text" class="input-text" value="'+linkurl+'" placeholder="" name="url[]"></p><p>IOS链接地址:<input type="text" class="input-text" value="'+ios_linkurl+'" placeholder="" name="ios_url[]"></p><p>Android链接地址:<input type="text" class="input-text" value="'+android_linkurl+'" placeholder="" name="android_url[]"></p><p>描述:<input type="text" class="input-text" value="'+desc+'" placeholder="" name="desc[]"></p><div id="filePicker" class="btn btn-secondary radius" onclick="_open(\'添加附件\',\'article-imageupload.html?type=image&idname=fileList'+i+'&api=ad&single=1&inputname=img[]\',\'710px\',\'470px\',true)">选择图片</div></div>');
	            		
	            		
	            		
	            		$(boxid).html('<img src="'+data.datas.ad_content[x].img_url+'"><input type="hidden" name="img[]" value="'+data.datas.ad_content[x].img+'">');
	            		index=i+1;
	            		// $(boxid).next("p").find("input").val(data.datas.ad_content[x].url);
	            	}
	            }
	            
	            if(data.datas.ad_state=='0'){
	                $("#radio-2").attr("checked",true);
	                $("#radio-1").attr("checked",false);
	            }else{
	                $("#radio-1").attr("checked",true);
	                $("#radio-2").attr("checked",false);
	            }

	            if(data.datas.is_public=='0'){
	                $("#radio-4").attr("checked",true);
	                $("#radio-3").attr("checked",false);
	            }else{
	                $("#radio-3").attr("checked",true);
	                $("#radio-4").attr("checked",false);
	            }

	            UE.getEditor('editor').addListener('ready', function (editor) {
		            UE.getEditor('editor').setContent(data.datas.ad_brief);
	            });

	    })
		
	}


	
	Validformsubmit("#form1");


	
	// 富文本编辑器
	getueidt()
	
	

});



function fj_close(obj){
	$(obj).parents("li").remove();
}


</script>
</body>
</html>